package org.sandbox2.domain.loan;

import java.util.Date;
import java.util.List;

import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;

@RooJavaBean
@RooToString
@RooEntity(finders = { "findLoanBalanceFormsByBorrowerIdAndPaymentDate" })
public class LoanBalanceForm {

	@Transient
	@NotNull
    Long borrowerId;

	@Transient
    Long loanId;

	@Transient
    Integer balance;

	@Transient
    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(style = "S-")
    private Date paymentDate;
    
    public static List<LoanBalanceForm> findLoanBalanceFormsByBorrowerIdAndPaymentDate(Long borrowerId, Date paymentDate) {
    	return LoanRepository.findBalanceAt(borrowerId, paymentDate);
    }
}
